//
//  NewsTableViewCell.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/21.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "NewsTableViewCell.h"

@implementation NewsTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
        
    }

    return self;
}

-(void)setupUI{
    
    UIButton *china = [self addBtnWithTitle:@"内地票房榜" imageName:@"v10_domesticTopListOnNews"];
    
    [china setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    
    [china mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self);
        
    }];
    
    UIButton *word = [self addBtnWithTitle:@"全球票房榜" imageName:@"v10_globalTopListOnNews"];
    
    [word setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    
    [word mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(china.mas_right);
        
    }];
    
    UIView *lineView = [[UIView alloc]init];
    
    lineView.backgroundColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    
    [self.contentView addSubview:lineView];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(word.mas_bottom);
        
        make.width.equalTo(self);
        
        make.height.equalTo(@0.5);
        
        make.left.equalTo(self);
        
    }];
    
    
    UIView *lineView1 = [[UIView alloc]init];
    
    lineView1.backgroundColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    
    [self.contentView addSubview:lineView1];
    
    [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(china);
        
        make.width.equalTo(@0.5);
        
        make.top.height.equalTo(word);
        
    }];

    

}


-(UIButton *)addBtnWithTitle:(NSString *)title imageName:(NSString *)imageName{
    
    UIButton *button = [[UIButton alloc]init];
    
    [button setTitle:title forState:UIControlStateNormal];
    
    UIImage *image = [UIImage imageNamed:imageName];
    
    [button setImageEdgeInsets:UIEdgeInsetsMake(0, -15, 0, 15)];
    
    UILabel *tempLabel = button.titleLabel;
    
    tempLabel.font = [UIFont systemFontOfSize:14];
    
    
    
    [button setImage:image forState:UIControlStateNormal];
    
    [self.contentView addSubview:button];
    
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.equalTo(self.contentView);
        
        make.width.equalTo(self).multipliedBy(0.5);
        
        make.height.equalTo(@60);
        
    }];
    
    return button;
    
}


@end
